const FORM = {
  TEXT_INPUT: 'textInput',
  TEXT_AREA: 'textArea',
  SELECT: 'select',
  DATEPICKER: 'datePicker',
  RADIO: 'radio',
  CHECKBOX: 'checkbox',
  UPLOAD: 'upload',
  CALCULATE: 'calculate',
};

const VISUAL = {
  TEXT: 'text',
  IMAGE: 'image',
  DIVIDER: 'divider',
};

const CONTAINER = {
  GROUP: 'group',
  GROUP_LIST: 'groupList',
  TABLE: 'table',
  TABLE_ROW: 'tableRow',
  TABLE_CELL: 'tableCell',
};

export default {
  ...FORM,
  ...VISUAL,
  ...CONTAINER,
};

export { FORM, VISUAL, CONTAINER };
export function isForm(type) {
  return isValueOf(type, FORM);
}

export function isVisual(type) {
  return isValueOf(type, VISUAL);
}

export function isContainer(type) {
  return isValueOf(type, CONTAINER);
}

function isValueOf(value, object) {
  for (const key in object) {
    if (value === object[key]) {
      return true;
    }
  }
}
